//
//  Ex_FlutterMethodCall.swift
//  flutter_baichuan
//
//  Created by dmcb on 2021/8/26.
//

import Foundation
// 随便定义一个数组，如果等于他就是空
private let EmptyNum : NSNumber = NSNumber(integerLiteral: 5285)
extension FlutterMethodCall {
    func getString(key: String) -> String {
        guard let result = (arguments as? Dictionary<String, Any>)?[key] as? String else {
            return ""
        }
        return result
    }
    
    func getNumber(key: String) -> NSNumber {
        guard let result = (arguments as? Dictionary<String, Any>)?[key] as? NSNumber else {
            return EmptyNum
        }
        return result
    }
    func getBool(key: String) -> Bool {
        guard let result = (arguments as? Dictionary<String, Any>)?[key] as? Bool else {
            return false
        }
        return result
    }
    
    func getDict(key: String) -> Dictionary<String, Any>? {
        guard let result = (arguments as? Dictionary<String, Any>)?[key] as? Dictionary<String, Any> else {
            return nil
        }
        return result
    }
}
